package com.wrater.zero.models.checkReportTemplate.controller;

import com.wrater.zero.common.base.ResultVo;
import com.wrater.zero.models.checkReportTemplate.entity.CheckReportTemplate;
import com.wrater.zero.models.checkReportTemplate.vo.CheckReportTemplateVO;
import com.wrater.zero.models.checkReportTemplate.service.CheckReportTemplateService;
import com.wrater.zero.common.utils.PageUtil;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Package:  com.wrater.zero.models.checkReportTemplate.controller;
 * @Description: <检查化验报告模板前端控制器>
 * @Author: qiaoxs
 * @CreateDate: 2021-04-07
 * @UpdateUser: qiaoxs
 * @UpdateDate: 2021-04-07
 * @UpdateRemark: <>
 * @Version: 1.0
 */
@RestController
@Api(tags = "检查化验报告模板-相关接口")
@RequestMapping(value = "/check/reportTemplate", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public class CheckReportTemplateController {
    @Autowired
    private CheckReportTemplateService checkReportTemplateService;

    /**
     * 根据id获取检查化验报告模板详情
     * @param id 主键
     * @return 检查化验报告模板详情
     * @author qiaoxs
     * @time 2021-04-07
     */
    @ApiOperation(value = "getById", notes = "根据id获取检查化验报告模板详情")
    @RequestMapping(value= "/getById/{id}", method=RequestMethod.GET)
    public ResultVo<CheckReportTemplateVO> getCheckReportTemplate(@PathVariable String id){
        return new ResultVo(checkReportTemplateService.getById(id).buildVo());
    }


    /**
    * 根据参数实体参数分页获取检查化验报告模板详情
    * @param vo    参数实体
    * @return      分页后的对象
    */
    @ApiOperation(value = "getListByPage", notes = "根据参数实体获取检查化验报告模板详情")
    @RequestMapping(value= "/getListByPage", method=RequestMethod.POST)
    public ResultVo<PageInfo<CheckReportTemplateVO>> getListByPage(@RequestBody CheckReportTemplateVO vo){
        CheckReportTemplate entity = vo.buildEntity();
        PageUtil.setPage(vo);
        List<CheckReportTemplateVO> list = entity.selectAllVo();
        return new ResultVo(PageUtil.getPageInfo(list));
    }

}